package options.view;

import controller.LevelHandler;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import options.controller.OptionsWindowListener;
import view.FrameWork;

public class OptionsWindow extends JDialog implements LevelHandler {

	private static final long serialVersionUID = -1598181954696777116L;
	@SuppressWarnings("unused")
	private OptionsWindowListener listener = null;
	private JPanel jContentPane = null;
	private JTabbedPane jTabbedPane = null;
	private FrameWork container = null;
	
	/**
	 * This is the default constructor
	 */
	public OptionsWindow(FrameWork container) {
		super(container);
		this.container = container;
		
		initialize();
		
		this.setEnabledContainer(false);
		
		listener = new OptionsWindowListener(this);
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(480, 360);
		ViewSettings.getSettings().centerDialog(this);
		this.setTitle("Opzioni");
		this.setResizable(false);
		this.setContentPane(getJContentPane());
		this.setVisible(true);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJTabbedPane(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jTabbedPane	
	 * 	
	 * @return javax.swing.JTabbedPane	
	 */
	public JTabbedPane getJTabbedPane() {
		if (jTabbedPane == null) {
			jTabbedPane = new JTabbedPane();
			jTabbedPane.setBounds(new java.awt.Rectangle(9,6,455,315));
			
			JPanel db = new OptionTabbedDB();
			db.setSize(jTabbedPane.getWidth(), jTabbedPane.getHeight());
			jTabbedPane.addTab("Connessione", null, db, null);
		}
		return jTabbedPane;
	}

	public void setEnabledContainer(boolean b) {
		this.container.setEnabled(b);

		if(b){
			this.container.transferFocus();
		}
	}
	

	public void dispose() {
		this.container.setEnabled(true);
		super.dispose();
	}
}
